package com.situ.week1.day1;

import org.junit.Test;

import java.util.Random;
import java.util.Scanner;

public class test1 {
    public static void main(String[] args) {

    }
    @Test
    public void test() {
        if (3 >=5 ) {
            System.out.println("3 >= 5");
        } else {
            System.out.println("3 < 5");
        }
    }

    @Test
    public void test1() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入成绩：");
        int score = scanner.nextInt();
        if (score < 0 || score > 100) {
            System.out.println("这是非法输入");
            return;
        }
        if (score >= 90 && score <= 90) {
            System.out.println("优秀");
        } else if (score >= 80 && score < 90) {
            System.out.println("良好");
        } else if (score >= 70 && score < 80) {
            System.out.println("一般");
        } else if (score >= 60 && score < 70) {
            System.out.println("及格");
        } else {
            System.out.println("不及格");
        }
    }

    @Test
    public void test2() {
        int num1 = 13;
        int num2 = 5;
        int max = 0;
        if (num1 >= num2) {
            max = num1;
        } else {
            max = num2;
        }
        System.out.println(max);

        int max1 = num1 >= num2 ? num1 : num2;
        System.out.println(max1);
    }
    @Test
    public void test3() {
        int age = 28;
        System.out.println("我的年龄是23岁 ");
        System.out.println("我的年龄是" + age + "岁");
        System.out.println(10 + 20 + "" +30);
        System.out.println("" + 10 + 20 + 30);
    }
    @Test
    public void test4() {
        int i = 1;
        while (i <= 5) {
            System.out.println("HelloWorld");
            i++;
        }
    }
    @Test
    public void test5() {
        for (int i = 0; i < 5; i++) {
            System.out.println("helloworld");
        }
    }

    @Test
    public void test6() {
        int sum = 0;
        for (int i = 1; i <= 100 ; i++) {
            System.out.println(i);
            sum += i;
            System.out.println("sum: "+sum);
        }
        System.out.println("sum: "+sum);
    }
    @Test
    public void test7() {
        int count = 0;
        for (int i = 1; i <= 100; i++) {
            if (i % 7 == 0) {
                System.out.println(i);
                count++;
            }
        }
        System.out.println("count: "+count);
    }
    @Test
    public void test8() {
        for (int i = 1; i <= 6; i++) {
            if (i == 3) {
                continue;
            }
            System.out.println(i);
        }
    }
    @Test
    public void test9() {
        for (int i = 1; i <= 5; i++) {
            if (i == 3) {
                break;
            }
            System.out.println(i);
        }
    }
    @Test
    public void test10() {
        for (int i = 0; i <= 5; i++) {
            System.out.println("i: " + i);
            for (int j = 0; j <= 5; j++) {
                if (j == 3) {
                    break;
                }
                System.out.println("j: " + j);
            }
        }
    }
    @Test
    public void test11() {
        int num = 200;
        while (true) {
            Scanner scanner = new Scanner(System.in);
            int number = scanner.nextInt();
//            Random random = new Random();
//            int number = random.nextInt(1000) + 1;
            if (num == number) {
                System.out.println("恭喜你猜对了");
                break;
            } else if (number == 0) {
                break;
            } else if (num > number) {
                System.out.println("太小了");
            } else {
                System.out.println("太大了");
            }
        }
    }
    @Test
    //随机生成一个整数1-1000
    public void test34() {
        Random random = new Random();
        // [0, 1000) + 1
        // [1, 1000]
        int num = random.nextInt(1000) + 1;
        System.out.println(num);
    }
    @Test
    public void test12() {
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 4; j++) {
                System.out.printf("*");
            }
            System.out.println("\n");
        }
    }
    @Test
    public void test13() {
        for (int i = 0; i < 5; i++) {
            for (int j = 0; j <= i; j++) {
                System.out.printf("*");
            }
            System.out.println("\n");
        }
    }
    @Test
    public void test14() {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= i; j++) {
                if (j == 1) {
                    System.out.print(j+"*"+i+"="+i*j);
                } else {
                    System.out.print(" "+j+"*"+i+"="+i*j);
                }
            }
            System.out.println();
        }
    }
    @Test
    public void test15() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = scanner.nextInt();
        System.out.println("请输入月份：");
        int mouth = scanner.nextInt();
        switch (mouth) {
            case 1:
            case 3:
            case 5:
            case 7:
            case 8:
            case 10:
            case 12:
                System.out.println("31天");
                break;
            case 4:
            case 6:
            case 9:
            case 11:
                System.out.println("30天");
                break;
            case 2:
                if (year % 4 == 0) {
                    System.out.println("29天");
                    break;
                } else {
                    System.out.println("28天");
                    break;
                }
            default:
                System.out.println("default");
                break;
        }
    }
    @Test
    public void test16() {
        System.out.println("请输入学生的成绩：");
        Scanner scanner = new Scanner(System.in);
        int score = scanner.nextInt();
        int a = score / 10;
        switch (a) {
            case 10:
                if (score % 10 != 0){
                    System.out.println("default");
                    break;
                } else if (score % 10 ==0) {
                    System.out.println("优秀");
                    break;
                }
            case 9:
                System.out.println("优秀");
                break;
            case 8:
                System.out.println("良好");
                break;
            case 7:
                System.out.println("一般");
                break;
            case 6:
                System.out.println("及格");
                break;
            case 5:
            case 4:
            case 3:
            case 2:
            case 1:
            case 0:
                System.out.println("不及格");
                break;
            default:
                System.out.println("default");
                break;
        }
    }
}

